package com.huiyuanai.service.role;

import com.huiyuanai.dao.Role;
import com.huiyuanai.pojo.role.RolePojo;
import com.huiyuanai.pojo.role.RolePojoImpl;
import com.huiyuanai.util.BaseUtil;
import org.junit.jupiter.api.Test;

import java.sql.Connection;
import java.util.List;

/**
 * @Author: liwan
 * @Description:
 * @Date: create in 2021/10/6
 */
public class RoleServiceImpl implements RoleService{

    private RolePojo rolePojo;

    public RoleServiceImpl() {
        rolePojo = new RolePojoImpl();
    }

    @Override
    public List<Role> getRoleList() throws Exception {
        Connection connection = BaseUtil.getConnectionDIY();
        List<Role> roleList = rolePojo.getRoleList(connection);
        BaseUtil.clostResour(connection, null, null);
        return roleList;
    }

    @Test
    public void t() {
        RoleService roleService = new RoleServiceImpl();
        try {
            List<Role> roleList = roleService.getRoleList();
            for (Role role : roleList) {
                System.out.println(role.getId() + "       " + role.getRoleName());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
